﻿package mortal.game.view.copy.defenseCopy.view
{
    import Message.DB.Tables.*;
    import com.mui.controls.*;
    import extend.language.*;
    import mortal.common.global.*;
    import mortal.component.gComplexList.*;
    import mortal.component.gconst.*;
    import mortal.game.cache.*;
    import mortal.game.resource.*;
    import mortal.game.resource.info.*;
    import mortal.game.resource.info.item.*;
    import mortal.game.resource.tableConfig.*;
    import mortal.game.view.common.*;
    import mortal.game.view.copy.ChallengeCopy.view.*;
    import mortal.game.view.copy.defenseCopy.*;

    public class DefenseCopyShopNewCatogeryHead extends GComplexListTitleBase
    {
        private var _btnBg:GLoadingButton;
        private var _txt:GTextFiled;
        private var _starPanel:StarPointPanel;
        private var _colorInfo:ColorInfo;
        private var _index:int;

        public function DefenseCopyShopNewCatogeryHead()
        {
            return;
        }// end function

        private function filterFun(param1:TDefenseCopyShopSell, param2:int, param3:Array) : Boolean
        {
            var _loc_4:* = new ItemData(param1.itemCode);
            return _loc_4.itemInfo.color == this._index;
        }// end function

        private function filterCopyCodeFun(param1:TDefenseCopyShopSell, param2:int, param3:Array) : Boolean
        {
            if (GameConst.GuideDefenseCopyCode == Cache.instance.copy.copyInfo.code)
            {
                return param1.copycode == GameConst.DefenseCopyCode;
            }
            return param1.copycode == Cache.instance.copy.copyInfo.code;
        }// end function

        private function updateTxt() : void
        {
            var _loc_1:Array = null;
            if (this._colorInfo)
            {
                if (DefenseCopyUtil.isEquipTab)
                {
                    _loc_1 = DefenseCopyShopConfig.instance.allEquipItem;
                    _loc_1 = _loc_1.filter(this.filterFun);
                    _loc_1 = _loc_1.filter(this.filterCopyCodeFun);
                    this._txt.text = Language.getStringByParam(50155, this._colorInfo.colorText, _loc_1.length);
                }
                else
                {
                    _loc_1 = DefenseCopyShopConfig.instance.allScrollItem;
                    _loc_1 = _loc_1.filter(this.filterCopyCodeFun);
                    this._txt.text = Language.getStringByParam(50157, _loc_1.length);
                }
            }
            return;
        }// end function

        public function updateUI() : void
        {
            this._starPanel.visible = DefenseCopyUtil.isEquipTab;
            return;
        }// end function

        override public function set data(param1:Object) : void
        {
            this._index = param1 as int;
            this._colorInfo = ColorConfig.instance.getItemColor(this._index);
            this._btnBg.styleName = "DefenseCopyShopHeadBtn" + this._index;
            this._txt.textColor = this._colorInfo.intColor;
            this._starPanel.totalStar = this._index + 1;
            this._starPanel.value = this._index + 1;
            this._starPanel.x = (5 - this._index) / 2 * 25 + 105;
            this.updateTxt();
            this.updateUI();
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            super.createDisposedChildrenImpl();
            this._btnBg = UIFactory.gLoadingButton("", 0, 0, 241, 47, this);
            this._txt = UIFactory.gTextField("", 1, 12, 220, 40, this, GlobalStyle.textFormatPutong.setBold(true).setSize(14));
            this._starPanel = UIFactory.getUICompoment(StarPointPanel);
            this._starPanel.setStarStyle(ImagesConst.PointStar, ImagesConst.PointStarNone, 25);
            UIFactory.setObjAttri(this._starPanel, 124, 10, -1, -1, this);
            return;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            super.disposeImpl(param1);
            this._btnBg.dispose(param1);
            this._txt.dispose(param1);
            this._starPanel.dispose(param1);
            this._btnBg = null;
            this._txt = null;
            this._starPanel = null;
            return;
        }// end function

    }
}
